# DrawSquare_TwoTurtles.py # # Description: Draws a square with a Turtle # given a colour and the size of the square's sides. # # Anne Lavergne # Date: Feb. 16 2024 # Import the turtle library import turtle def drawSquare(aTurtle, aColour, aSideSize): """Have "aTurtle" draw a square of colour "aColor" and of side "sideSize".""" # Set aTurtle's pen (tail) to aColour aTurtle.color(aColour) # Tell aTurtle to draw four sides # starting with aTurtle faces east at (0,0) for side in range(4): # 0,1,2,3 aTurtle.forward(aSideSize) aTurtle.left(90) return # ***Main part of the program # Creates a graphics window "canvas" canvas = turtle.Screen() # Give a background colour to "canvas" canvas.bgcolor("yellow") # Create a turtle named "tt1" tt1 = turtle.Turtle() # Set "tt1" to a slow speed tt1.speed(1) # Move "tt1" to top right of canvas tt1.penup() tt1.goto(200,200) tt1.pendown() # Create a turtle named "tt2" tt2 = turtle.Turtle() # Move "tt2" to bottom letf of canvas tt2.goto(-200,-200) # Tell "tt1" to draw a square of "hotpink" and of 150 drawSquare(tt1, "hotpink", 150) # Tell "tt2" to draw a square of "blue" and of 50 drawSquare(tt2, "blue", 50) tt2.hideturtle() # Clock on canvas to exit canvas.exitonclick()